//
//  ViewController.swift
//  P0001_MyView
//
//  Created by yao_yu on 14-8-31.
//  Copyright (c) 2014年 yao_yu. All rights reserved.
//

import UIKit

class ViewController: UIViewController {
    
    var lblResult = UILabel(frame: CGRectMake(10, 200, 300, 100))
                            
    override func viewDidLoad() {
        super.viewDidLoad()
        
        setupViews()

    }
    
    func setupViews(){
        var toolBar = UIToolbar(frame:CGRectMake(10.0, 120.0, 300.0, 32))
        toolBar.barStyle = .BlackTranslucent
        toolBar.tintColor = UIColor.greenColor()
        toolBar.backgroundColor = UIColor.blueColor()
        
        var flexibleSpace = UIBarButtonItem(barButtonSystemItem:UIBarButtonSystemItem.FlexibleSpace, target:nil, action:nil)
        var barBtnItemA = UIBarButtonItem(title: "1", style:UIBarButtonItemStyle.Plain, target:self, action:"barButtonItemClicked:")
        var barBtnItemB = UIBarButtonItem(title: "2", style:UIBarButtonItemStyle.Plain, target:self, action:"barButtonItemClicked:")
        var barBtnItemC = UIBarButtonItem(title: "3", style:UIBarButtonItemStyle.Plain, target:self, action:"barButtonItemClicked:")
        var barBtnItemD = UIBarButtonItem(title: "4", style:UIBarButtonItemStyle.Plain, target:self, action:"barButtonItemClicked:")
        
        toolBar.items = [flexibleSpace, barBtnItemA, flexibleSpace, barBtnItemB, flexibleSpace, barBtnItemC, flexibleSpace, barBtnItemD, flexibleSpace]
        self.view.addSubview(toolBar)
        
        lblResult.textAlignment = NSTextAlignment.Center
        self.view.addSubview(lblResult)
    }
    
    func barButtonItemClicked(sender:UIBarButtonItem!){
        lblResult.text = "点了按钮\(sender.title!)"
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

